package com.ruoyi.report.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.report.domain.ReportRefineryInfo;
import com.ruoyi.report.service.IReportRefineryInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 炼厂信息Controller
 * 
 * @author scp
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/report/refinery")
public class ReportRefineryInfoController extends BaseController
{
    @Autowired
    private IReportRefineryInfoService reportRefineryInfoService;

    /**
     * 查询炼厂信息列表
     */
    @PreAuthorize("@ss.hasPermi('report:refinery:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportRefineryInfo reportRefineryInfo)
    {
        startPage();
        List<ReportRefineryInfo> list = reportRefineryInfoService.selectReportRefineryInfoList(reportRefineryInfo);
        return getDataTable(list);
    }

    @GetMapping("/listNoPage")
    public TableDataInfo listNoPage(ReportRefineryInfo reportRefineryInfo)
    {
        List<ReportRefineryInfo> list = reportRefineryInfoService.selectReportRefineryInfoList(new ReportRefineryInfo());
        return getDataTable(list);
    }
    /**
     * 导出炼厂信息列表
     */
    @PreAuthorize("@ss.hasPermi('report:refinery:export')")
    @Log(title = "炼厂信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ReportRefineryInfo reportRefineryInfo)
    {
        List<ReportRefineryInfo> list = reportRefineryInfoService.selectReportRefineryInfoList(reportRefineryInfo);
        ExcelUtil<ReportRefineryInfo> util = new ExcelUtil<ReportRefineryInfo>(ReportRefineryInfo.class);
        return util.exportExcel(list, "炼厂信息数据");
    }

    /**
     * 获取炼厂信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:refinery:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(reportRefineryInfoService.selectReportRefineryInfoById(id));
    }

    /**
     * 新增炼厂信息
     */
    @PreAuthorize("@ss.hasPermi('report:refinery:add')")
    @Log(title = "炼厂信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportRefineryInfo reportRefineryInfo)
    {
        return toAjax(reportRefineryInfoService.insertReportRefineryInfo(reportRefineryInfo));
    }

    /**
     * 修改炼厂信息
     */
    @PreAuthorize("@ss.hasPermi('report:refinery:edit')")
    @Log(title = "炼厂信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportRefineryInfo reportRefineryInfo)
    {
        return toAjax(reportRefineryInfoService.updateReportRefineryInfo(reportRefineryInfo));
    }

    /**
     * 删除炼厂信息
     */
    @PreAuthorize("@ss.hasPermi('report:refinery:remove')")
    @Log(title = "炼厂信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(reportRefineryInfoService.deleteReportRefineryInfoByIds(ids));
    }
}
